package com.learn.qy.cp.config.impl;

import com.learn.qy.cp.config.WxCpConfigStorage;

import java.io.Serializable;

/**
 * @author : Yu.Tan
 * @date : 2023/6/25 14:52
 * @desc : **
 */
public class WxCpConfigStorageImpl implements WxCpConfigStorage, Serializable {

    private static final long serialVersionUID = 3832287138979437770L;

    private volatile String corpId;
    private volatile String agentSecret;
    protected volatile Integer agentId;
    private volatile String baseApiUrl;

    public void setCorpId(String corpId) {
        this.corpId = corpId;
    }

    public void setAgentSecret(String agentSecret) {
        this.agentSecret = agentSecret;
    }
    public void setAgentId(Integer agentId) {
        this.agentId = agentId;
    }


    @Override
    public String getCorpId() {
        return this.corpId;
    }

    @Override
    public String getAgentSecret() {
        return this.agentSecret;
    }

    @Override
    public Integer getAgentId() {
        return this.agentId;
    }


    @Override
    public void setBaseApiUrl(String baseUrl) {
        this.baseApiUrl = baseUrl;
    }

    @Override
    public String getApiUrl(String path) {
        if (this.baseApiUrl == null) {
            this.baseApiUrl = "https://qyapi.weixin.qq.com";
        }
        return this.baseApiUrl + path;
    }
}
